﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Laby
{
    class Program
    {
        static bool IsValidNumber(string str)
        {
            if (str == "")
                return false;

            int i = 0;
            while (i < str.Length && str[i] <= '9' && str[i] >= '0')
                i++;
            return i == str.Length;
                    
        }

        static void Main(string[] args)
        {
            while (true)
            {
                string width, height;
                do
                {
                    Console.Write("Veuillez entrer le nombre de lignes : ");
                    width = Console.ReadLine();
                }
                while (!IsValidNumber(width));

                do
                {
                    Console.Write("Veuillez entrer le nombre de colonnes : ");
                    height = Console.ReadLine();
                }
                while (!IsValidNumber(height));

                Maze maze = new Maze(int.Parse(width), int.Parse(height));
                maze.InitializeLaby();
                maze.InitializeNeighbors();
                maze.GenerateLaby();
                maze.Print();
                Console.ReadLine();
                Console.Clear();
                maze.Print(maze.SolveLaby());
                Console.ReadLine();
                Console.Clear();

            }
        }
    }
}
